#pragma once

#include <string>
#include "producer/client/MessagePublisher.h"
#include "producer/client/RouteInfoDownloader.h"
#include "producer/client/ProducerMediator.h"

namespace zeroplus::mq
{
    using namespace producer;
    class ProducerController
    {
    private:
        std::shared_ptr<producer::RouteInfoDownloader> routeInfoDownloader_;
        std::shared_ptr<producer::MessagePublisher> messagePublisher_;
        std::shared_ptr<producer::ProducerMediator> mediator_;

    public:
        ProducerController(const std::string &uri);

        ~ProducerController();

        void Start();

        template <typename BodyT>
        bool Publish(Message<BodyT> msg)
        {
            return messagePublisher_->Publish(msg.getHeader(), msg.getBytes());
        }
    };
}
